/*
 * @copyright fxsen <br/>
 * @date 2022/3/30 15:43 <br/>
 * @email <a href="mailto:fxsen@foxmail.com">
 * @author fxsen
 */
package com.fxsen.commons.web.core.config;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * mybatisPlus配置类
 * @author fxsen
 * @date 2022/3/30 15:43
 * @email <a href="mailto:fxsen@foxmail.com">
 */
@Configuration
@MapperScan("com.fxsen.**.mapper")
public class MybatisPlusConfig {
    public MybatisPlusConfig() {
    }

    @Bean
    public DefineMethodConfig createMethodConfig() {
        return new DefineMethodConfig();
    }

    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        PaginationInnerInterceptor page = new PaginationInnerInterceptor(DbType.MYSQL);
        page.setOverflow(false);
        interceptor.addInnerInterceptor(page);
        return interceptor;
    }
}
